// 又是一道好久之前就想做的题
// 感谢https://www.luogu.com.cn/article/225wekr2
#include <bits/stdc++.h>
using namespace std;

const int R = 70;
int a[R], maxlen, tot, len, piece;
bool use[R];
bool dfs(int cnt, int sum, int last)
{
	if (cnt > piece)
	{
		return true;
	}
	if (sum == len)
	{
		return dfs(cnt + 1, 0, 1);
	}
	int fail = 0;
	for (int i = last; i <= tot; ++i)
	{
		if (!use[i] && a[i] + sum <= len && a[i] != fail)
		{
			use[i] = true;
			if (dfs(cnt, sum + a[i], i + 1)) // 成功，i+1别写成last+1！！！
			{
				return true;
			}
			use[i] = false;
			fail = a[i];
			if (sum == 0 || sum + a[i] == len) // 如果当前是第一根且失败，或者当前是最后一根且失败，则方案失败
			{
				return false;
			}
		}
	}
	return false; // 如果成功，则一定会在之前return true，所以到了结尾一定失败
}
int read() // 不写快读会超5ms
{
	int res = 0;
	char c = getchar();
	while (!isdigit(c))
	{
		c = getchar();
	}
	while (isdigit(c))
	{
		res = (res << 1) + (res << 3) + (c ^ 48);
		c = getchar();
	}
	return res;
}
int main()
{
	int n = read(), x;
	while (n--)
	{
		x = read();
		if (x <= 50)
		{
			a[++tot] = x;
			maxlen += x;
		}
	}
	sort(a + 1, a + tot + 1);
	reverse(a + 1, a + tot + 1);
	for (len = a[1]; len <= maxlen; ++len)
	{
		if (maxlen % len)
		{
			continue;
		}
		memset(use, false, sizeof(use));
		piece = maxlen / len;
		if (dfs(1, 0, 1))
		{
			break;
		}
	}
	printf("%d", len);
	return 0;
}
